// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "AbilitySystemInterface.h"
#include "GameFramework/Character.h"
#include "Interaction/CombatInterface.h"
#include "StarrySkyCharacterBase.generated.h"

class UGameplayAbility;
class UGameplayEffect;
class UAttributeSet;
class UAbilitySystemComponent;

UCLASS(Abstract)
class STARRYSKY_API AStarrySkyCharacterBase : public ACharacter,public IAbilitySystemInterface,public ICombatInterface
{
	GENERATED_BODY()

public:
	AStarrySkyCharacterBase();

	virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
	UAttributeSet* GetAttributeSet() const { return AttributeSet;}
	
	/** Combat Interface */
	//获取武器插槽的位置
	virtual FVector GetCombatSocketLocation_Implementation(const FGameplayTag& MontageTag) override;
	/** End Combat Interface */
protected:
	virtual void BeginPlay() override;

	//角色武器的模型组件
	UPROPERTY(EditAnywhere, Category = "Combat")
	TObjectPtr<USkeletalMeshComponent> Weapon;
	
	//添加武器插槽的名称
	UPROPERTY(EditAnywhere, Category = "Combat")
	FName WeaponTipSocketName;
	
	//角色基础移动速度
    UPROPERTY(EditAnywhere,BlueprintReadOnly,Category="Combat")
    float BaseWalkSpeed=600.f;

	//能力系统组件
	UPROPERTY()
	TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent;
	//属性集
	UPROPERTY()
	TObjectPtr<UAttributeSet> AttributeSet;
	virtual void InitAbilityActorInfo();

	//添加应用默认属性的游戏效果
	UPROPERTY(EditAnywhere,BlueprintReadOnly, Category = "Attributes")
	TSubclassOf<UGameplayEffect> DefaultPrimaryAttributes;

	//添加应用默认次要属性的游戏效果
	UPROPERTY(EditAnywhere,BlueprintReadOnly, Category = "Attributes")
	TSubclassOf<UGameplayEffect> DefaultSecondaryAttributes;

	//添加应用默认重要属性的游戏效果
	UPROPERTY(EditAnywhere,BlueprintReadOnly, Category = "Attributes")
	TSubclassOf<UGameplayEffect> DefaultVitalAttributes;

	//根据游戏效果类，级别添加游戏效果应用游戏效果到目标的能力系统组件中
	void ApplyEffectToSelf(TSubclassOf<UGameplayEffect> GameplayEffectClass, float Level) const;
	//通过游戏效果初始化默认属性
	virtual void InitializeDefaultAttributes() const;

	//添加初始化能量
	void AddCharacterAbilities();
private:
	//启动能力数组
	UPROPERTY(EditAnywhere, Category = "Abilities")
	TArray<TSubclassOf<UGameplayAbility>> StartupAbilities;
};


